from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField, TextAreaField
from wtforms.validators import DataRequired, EqualTo, Email, Length

class RegisterForm(FlaskForm):
    username = StringField('用户名', validators=[DataRequired(), Length(min=3, max=20)])
    password = PasswordField('密码', validators=[DataRequired(), Length(min=6)])
    confirm_password = PasswordField('确认密码', validators=[DataRequired(), EqualTo('password')])
    email = StringField('邮箱', validators=[DataRequired(), Email()])
    submit = SubmitField('提交')
    
    # 禁用CSRF保护以便测试
    class Meta:
        csrf = False

class LoginForm(FlaskForm):
    username = StringField('用户名', validators=[DataRequired()])
    password = PasswordField('密码', validators=[DataRequired()])
    submit = SubmitField('登录')
    
    # 禁用CSRF保护以便测试
    class Meta:
        csrf = False

class EditProfileForm(FlaskForm):
    username = StringField('用户名', validators=[DataRequired(), Length(min=3, max=20)])
    email = StringField('邮箱', validators=[DataRequired(), Email()])
    address = TextAreaField('地址', validators=[Length(max=200)])
    submit = SubmitField('更新信息')
    
    # 禁用CSRF保护以便测试
    class Meta:
        csrf = False